package com.player;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.Input.Keys;

public class Controls implements InputProcessor {
	
	private Player player;
	public enum directions {LEFT,RIGHT, JUMP, ATTACK, SPELL1, SPELL2, SPELL3, ULTI, STOP};
	
	public Controls (Player player) {
		this.player = player;
	}

	public void polling() {
		if(Gdx.input.isKeyPressed(Input.Keys.A)){
			player.move(directions.LEFT);
        }
		
		if(Gdx.input.isKeyPressed(Input.Keys.D)){
			player.move(directions.RIGHT);
        }
		
		if(Gdx.input.isKeyPressed(Input.Keys.R)){
			player.move(directions.ULTI);
        }
		
		if(Gdx.input.isKeyPressed(Input.Keys.SPACE)){
			player.move(directions.JUMP);
        }
		
		if(Gdx.input.isTouched(Input.Buttons.LEFT)){
			player.move(directions.ATTACK);
        }
	}
	
	@Override
	public boolean keyDown(int keycode) {
		switch (keycode) {
		case Keys.Q:
			player.move(directions.SPELL1);
			break;
		case Keys.W:
			player.move(directions.SPELL2);
			break;
		}
		return true;
	}

	@Override
	public boolean keyUp(int keycode) {
		switch (keycode) {
		case Keys.A:
		case Keys.D:
			player.move(directions.STOP);
			break;
		}
		return true;
	}

	@Override
	public boolean keyTyped(char character) {
		return false;
	}

	@Override
	public boolean touchDown(int screenX, int screenY, int pointer, int button) {
		return false;
	}

	@Override
	public boolean touchUp(int screenX, int screenY, int pointer, int button) {
		return false;
	}

	@Override
	public boolean touchDragged(int screenX, int screenY, int pointer) {
		return false;
	}

	@Override
	public boolean mouseMoved(int screenX, int screenY) {
		return false;
	}

	@Override
	public boolean scrolled(int amount) {
		return false;
	}

}
